<?php

require_once('Zend/Form/Element/Button.php');
require_once('Zend/Form/Element/Hash.php');

class BlogAdmin_Post_RebuildSearch extends Madoqua_Form
{
    public function __construct($options = null)
    {
        parent::__construct($options);

        $this->setMethod('post');
        $this->setAttrib('id', 'rebuild-index');

        $this->setRouteAction(array(
            'action' => 'rebuildindex',
            'controller' => 'post'
        ), 'blog_admin', true);

        $hash = new Zend_Form_Element_Hash('hash');
        $hash->setSalt(substr(md5(uniqid()), 1, 8));

        $button = new Zend_Form_Element_Button('Rebuild', array('escape' => false));

        $this->addElements(array($hash, $button));
    }

    public function setButtonGraphic($img)
    {
        $this->getElement('Rebuild')->setLabel("<img src=\"$img\" /><span class=\"button\">Rebuild Index</span>");
    }
}